package com.share.forkjoin;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

/**
 * created by caifan 2018/09/24
 */
public class ForkJoinDemo {
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        ForkJoinPool forkJoinPool = new ForkJoinPool();
        ForkJoinTask<Integer> result = forkJoinPool.submit(new SumTask(0, 100000000));
        System.out.println("result:" + result.invoke());
        long endTime = System.currentTimeMillis();
        System.out.println("耗时：" + (endTime - startTime) );
        forkJoinPool.shutdown();
    }
}
